// PVS 3/6/2008 - added to validate addresses with UPS Online Tools

using System;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Commerce.Common;

namespace Commerce.Providers
{
    public class AddressValidateCollection : List<AddressValidate>
    {

        public void Load(IDataReader rdr)
        {
            AddressValidate option;
            while (rdr.Read())
            {
                option = new AddressValidate();
                option.Load(rdr);
                this.Add(option);
            }
        }

    }
    
    public class AddressValidate
    {

        private string _statusCode;

        public string statusCode
        {
            get { return statusCode; }
            set { statusCode = value; }
        }

        private string _statusDescription;

        public string statusDescription
        {
            get { return _statusDescription; }
            set { _statusDescription = value; }
        }

        private int _rank;

        public int rank
        {
            get { return _rank; }
            set { _rank = value; }
        }

        private decimal _quality;

        public decimal quality
        {
            get { return _quality; }
            set { _quality = value; }
        }

        private string _city;

        public string city
        {
            get { return _city; }
            set { _city = value; }
        }

        private string _state;

        public string state
        {
            get { return _state; }
            set { _state = value; }
        }

        private string _zipLow;

        public string zipLow
        {
            get { return _zipLow; }
            set { _zipLow = value; }
        }

        private string _zipHigh;

        public string zipHigh
        {
            get { return _zipHigh; }
            set { _zipHigh = value; }
        }

        private string _returnDisplay;

        public string returnDisplay
        {
            get { return _returnDisplay; }
            set { _returnDisplay = value; }
        }
	


        public void Load(IDataReader rdr)
        {
            try { this.rank = int.Parse(rdr["Rank"].ToString()); }
            catch { };
            try { this.quality = (decimal)rdr["Quality"]; }
            catch { };
            try { this.city = rdr["City"].ToString(); }
            catch { };
            try { this.state = rdr["StateProvinceCode"].ToString(); }
            catch { };
            try { this.zipLow = rdr["PostalCodeLowEnd"].ToString(); }
            catch { };
            try { this.zipHigh = rdr["PostalCodeHighEnd"].ToString(); }
            catch { };
            try 
            {
                this.returnDisplay = rdr["City"].ToString();
                this.returnDisplay += ", " + rdr["StateProvinceCode"].ToString();
                this.returnDisplay += " - ZIP Ranage: " + rdr["PostalCodeLowEnd"].ToString();
                this.returnDisplay += " - " + rdr["PostalCodeHighEnd"].ToString(); 
            }
            catch { };
        }
	
	
	
	

    }

}
